#include "TobiiDeviceBase.h"


TobiiDeviceBase::TobiiDeviceBase(IODeviceContext* context)
	: IODeviceWithoutThreadSupport(IO_DEVICE_TOBII, context)
{
}


TobiiDeviceBase::~TobiiDeviceBase()
{
}

bool TobiiDeviceBase::RegisterConnectionStateChangedHandler()
{
	auto connectionStateChangedTrampoline = [](TX_CONNECTIONSTATE connectionState, TX_USERPARAM userParam)
	{
		static_cast<TobiiDeviceBase*>(userParam)->OnEngineConnectionStateChanged(connectionState, userParam);
	};

	bool success = txRegisterConnectionStateChangedHandler(m_hContext, &m_hConnectionStateChangedTicket, connectionStateChangedTrampoline, this) == TX_RESULT_OK;
	return success;
}

bool TobiiDeviceBase::RegisterSnapshotCommittedHandler()
{
	return true;
}

bool TobiiDeviceBase::RegisterEventHandler()
{
	auto eventHandlerTrampoline = [](TX_CONSTHANDLE hObject, TX_USERPARAM userParam)
	{
		static_cast<TobiiDeviceBase*>(userParam)->OnEvent(hObject, userParam);
	};

	bool success = txRegisterEventHandler(m_hContext, &m_hEventHandlerTicket, eventHandlerTrampoline, this) == TX_RESULT_OK;
	return success;
}